import random


def get_user_choice():
    while True:
        user_choice = input("请选择（石头/剪刀/布）：").lower()
        if user_choice in ["石头", "剪刀", "布"]:
            return user_choice
        else:
            print("无效的选择，请重新输入！")


def get_computer_choice():
    choices = ["石头", "剪刀", "布"]
    return random.choice(choices)


def determine_winner(user_choice, computer_choice):
    if user_choice == computer_choice:
        return "平局"
    elif (
            (user_choice == "石头" and computer_choice == "剪刀") or
            (user_choice == "剪刀" and computer_choice == "布") or
            (user_choice == "布" and computer_choice == "石头")
    ):
        return "用户胜利"
    else:
        return "电脑胜利"


def play_game():
    print("欢迎来到石头剪刀布游戏！")
    while True:
        user_choice = get_user_choice()
        computer_choice = get_computer_choice()
        print(f"用户选择：{user_choice}")
        print(f"电脑选择：{computer_choice}")
        winner = determine_winner(user_choice, computer_choice)
        print(f"结果：{winner}")
        play_again = input("再玩一局？（是/否）：").lower()
        if play_again != "是":
            break
    print("谢谢游玩！")


play_game()
